﻿ using System;
using System.Collections.Generic;
using System.Text;
using CMN.DAL;
using CMN.Entity;
using System.Data;
using System.Data.Common;
namespace CMN.BLL
{
     /// <summary>
    ///  (投票)
    /// </summary>
    public class Normal_Vote
    {
        #region "Normal_Vote (投票 ) - Method"
        /// <summary>
        /// 新增/删除/修改 Normal_VoteEntity (投票)
        /// </summary>
        /// <param name="fam">Normal_VoteEntity实体类</param>
        /// <returns>-1:存储过程执行失败,-2:存在相同的主键,Insert:返回插入自动ID,Update:返回更新记录数,Delete:返回删除记录数</returns>
        public  Int32 InsertUpdateDelete(Normal_VoteEntity fam)
        {
            return DALHelper.CMNHelper.Normal_VoteInsertUpdateDelete(fam);
        }
        /// <summary>
        /// 根据Id返回 Normal_VoteEntity实体类 单笔资料 (投票)
        /// </summary>
        /// <param name="Id">Id 递增Id</param>
        /// <returns>返回 Normal_VoteEntity实体类 Id为0则无记录</returns>
        public  Normal_VoteEntity  Disp(Int32 Id)
        {
            Normal_VoteEntity fam = null;
            QueryParam qp = new QueryParam();
            qp.PageIndex = 1;
            qp.PageSize = 1;
            qp.Where = string.Format("{0}.{1} = {2}", "Normal_Vote", "Id", Id.ToString());
            int RecordCount = 0;
            List<Normal_VoteEntity> lst = List(qp, out RecordCount);
            if (RecordCount > 0)
            {
                fam = lst[0];
            }
            return fam;
        }

        /// <summary>
        /// 返回Normal_VoteEntity实体类的List对象 (投票)
        /// </summary>
        /// <param name="qp">查询类(非安全函数,传入参数请进行Sql字符串过滤)</param>
        /// <param name="RecordCount">返回记录总数</param>
        /// <returns>Normal_VoteEntity实体类的List对象(投票)</returns>
        public  List<Normal_VoteEntity> List(QueryParam qp, out int RecordCount)
        {
            qp.TableName = "Normal_Vote";
            if (string.IsNullOrEmpty(qp.Orderfld))
            {
                qp.Orderfld = "Id desc";
            }
            if (string.IsNullOrEmpty(qp.ReturnFields))
            {
                qp.ReturnFields = "*";
            }
            if (string.IsNullOrEmpty(qp.NotInRowName))
            {
                qp.NotInRowName = "Id";
            }
            return DALHelper.CMNHelper.Normal_VoteList(qp,true, out RecordCount);
        }
        
        /// <summary>
        /// 批量删除((投票))
        /// </summary>
        /// <param name="idList">删除数组</param>
        /// <returns>删除的总个数</returns>
        public  int DelList(string idList)
        {
            string strDel = string.Concat("delete from  Normal_Vote where Id in(", idList, ")");
            return DALHelper.CMNHelper.ExecuteNonQuery(CommandType.Text, strDel, null);
        }
        #endregion
   }
 }
 